﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DelayDestory : MonoBehaviour
{
    public float Second;
    public float RandomTime;

    private float _start;

    // Use this for initialization
    private void OnEnable()
    {
        _start = Time.time + Random.Range(-RandomTime, RandomTime);
    }

    // Update is called once per frame
    private void FixedUpdate()
    {
        if (_start + Second < Time.time)
        {
            Destroy(gameObject);
        }
    }
}